package Work4.Slay_the_Maze.GameSystem;

import Work4.Slay_the_Maze.Player.*;
import Work4.Slay_the_Maze.GameSystem.*;
import Work4.Slay_the_Maze.Monsters.*;
import java.util.ArrayList;

public class BattleSystem {
	public boolean Battle(Player player,ArrayList<Monster> monsters,boolean monstertype) {
		System.out.println("------战斗开始------");
		player.simplerest();
		boolean isdone = false;
		do {
			for(int i=monsters.size()-1;i>=0;i--) {
				monsters.get(i).PrintInfo();
			}
			System.out.println("------你的回合------");
			player.Action(player,monsters);
			System.out.println("------怪物回合------");
			for(int i=monsters.size()-1;i>=0;i--) {
				if(monsters.get(i).getHp()<=0) {
					monsters.remove(i);
				}else {
					monsters.get(i).Action(player,monsters.get(i));
				}
			}
			System.out.println("------------------");
			if(player.getHp()<=0) {
				System.out.println("你输了");
				isdone = true;
			}
			if(monsters.size()==0) {
				System.out.println("胜利！");
				isdone = true;
			}
		}while(!isdone);
		if(player.getHp()==0) {
			return false;
		}
		if(monsters.size()==0) {
			BattleReward br=new BattleReward();
			br.Reward(player);
			if(!monstertype) {
				br.MoreReward(player);
			}//怪物类型不为true时代表遇到强怪,额外奖励
			return true;
		}
		return true;
	}
}
